<?php
namespace Admin\Service;
use Think\Service\BasicService;

class GoodsService extends BasicService{
	public function insert($model){
		return $this->db->add($model);
	}

	public function remove($condition){
		return $this->db->where($condition)->delete();
	}

	public function update($model,$save=array()){
		return $this->db->where($model)->save($save);
	}

	public function find($condition){
		$data =  $this->db->where($condition)->find();
		switch($data['PAGE']){
			case 1 :
				$data['PAGES'] = '主页';
				break;
			case 2 :
				$data['PAGES'] = '二级子页面1';
				break;
			case 3 :
				$data['PAGES'] = '二级子页面2';
				break;
			case 4 :
				$data['PAGES'] = '二级子页面3';
				break;
			case 5 :
				$data['PAGES'] = '二级子页面4';
				break;
			default :
				$data['PAGES'] = '其他';
		}
		switch($data['TYPE']){
			case 1 :
				$data['TYPES'] = '热销商品';
				break;
			case 2 :
				$data['TYPES'] = '底部浏览商品';
				break;
			default :
				$data['TYPES'] = '其他';
		}
		return $data;
	}

	public function query($condition){
		return $this->db->where($condition)->order('SORT')->select();
	}

}

?>